/**
 * @author Javen 
 * @copyright 2018-09-22 17:37:50 javendev@126.com 
 * @description webSocket 测试 
 */
let Global = require("Global");
let customComponent = require("CustomComponent");
cc.Class({
    extends: customComponent,

    properties: {

    },

    // onLoad () {},
    playClickAudio() {
        this._super();
    },
    start() {
        this._super();
        this.initWebSocketResponseCallBack();
    },

    initWebSocketResponseCallBack() {
        Global.loginResponse = this.loginSocketCallBack.bind(this);
    },
    loginSocketCallBack(login) {
        BKTools.log("Userid>" + login.getUserid());
        BKTools.log("Nickname>" + login.getNickname());
    },

    // update (dt) {},
    btnClick(event, data) {
        this.playClickAudio();
        if (data == 'webSocket') {
            cc.log("点击事件:");
            this._webSocket.toLogin();
        } else if (data == 'skip') {
            // this.node.runAction(cc.sequence(cc.toggleVisibility(),flipXAction,flipYAction,cc.toggleVisibility()));
            this.setMoveX();
        } else if (data == 'back') {
            cc.director.loadScene("welcome");
        }
    },
    //左右抖动
    setMoveX() {
        let self = this;
        let playerDouCall = function () {
            let action1 = cc.toggleVisibility();

            let action2 = cc.toggleVisibility();
            var action3 = cc.speed(action2, 0.5);

            let finished = cc.callFunc(function () {
                cc.log("完成动画");
            }, this);
            self.node.runAction(cc.sequence(cc.repeat(cc.sequence(action1, action3), 5), finished));
        };
        self.scheduleOnce(playerDouCall, 3);
    },
});